<div class="loading-container"><div class="loader"></div></div>

<div class="wrapper wrapper-shadow wrapper-list"> 
	<!-- list data wrapper -->
	<div class="result-wrapper no-padding">
   	<div class="result-body">
   		<div class="tabs">
      	<ul class="nav nav-tabs widget no-margin-bottom">
        	<li class="active"> 
         		<a href="#tab-content" data-toggle="tab"> 
         			<span class="menu-icon"><i class="fa fa-user-plus"></i></span> 通知信息
           	</a>
         	</li>
        </ul>
        <div class="tab-content no-border xs-padding">
					<div class="tab-pane active" id="tab-content">
           	<div id="toolbar" class="btn-group">
					    <button type="button" class="btn btn-success" onclick="handlerCreate(this);"  data-editor-path="/miwawa/content/system/admin/notify/editor/" data-editor-page="jpush.html">
			        	<i class="glyphicon glyphicon-random"></i> 新增
					    </button>
						</div>
           	<table data-ajax="handlerSearch" 
       					 	 data-method="post" 
       					 	 data-search="true" 
       					 	 data-toolbar="#toolbar" 
       					 	 data-id-field="id" 
       					 	 data-unique-id="id" 
       					 	 data-pagination="true" 
       					 	 data-show-toggle="true" 
       					 	 data-show-refresh="true" 
       					 	 data-show-columns="true" 
       					 	 data-check-on-init="true" 
       					 	 data-click-to-select="true" 
       					 	 data-side-pagination="server" 
       					 	 data-mobile-responsive="true" 
           				 data-event-onload="handlerSuccess" 
       					 	 data-form-search="#search-form-notify" id="table-notify" class="bootstrap-table">
							<thead>
								<tr>
									<th data-checkbox="true"></th>
									<th data-field="id" 				data-visible="false" data-switchable="false">ID</th>
									<th data-field="title" 			data-halign="center" >标题</th>
									<th data-field="message" 		data-halign="center" >内容</th>
									<th data-field="createDate" data-halign="center" >时间</th>
									<th data-field="username" 	data-halign="center" >用户</th>
									<th data-field="status" 		data-halign="center" >状态</th>
									<th data-field="operator" 	data-halign="center" data-width="95" data-formatter="renderOperator" data-table-target="notify">操作</th>
								</tr>
							</thead>
						</table>
        	</div>
      	</div>
    	</div>
   	</div>
	</div>

	<!-- form editor wrapper -->
	<div class="editor-wrapper">
		
	</div>
</div>
<!-- PAGE CONTENT END =============================================== -->

<!-- 查询表单 ========================================================= -->
<form id="search-form-notify" action="/miwawa/default/common/search.json" method="post" 
			name="org.framework.common.api.entity.CommonMessage">
			<input type="hidden" name="info" id="info"  data-search-group="and" data-search-operation="EQ">
			<input type="hidden" name="invalid" value="F" data-search-group="and" data-search-operation="EQ">
			<input type="hidden" data-search-sort="createDate" data-search-order="desc">
</form>
<!-- 更新状态 ========================================================= -->
<form id="modify-form-notify" action="/miwawa/default/common/update" method="post" name="org.framework.common.api.entity.CommonMessage"></form>
<!-- 删除表单 ========================================================= -->
<form id="remove-form-notify" action="/miwawa/default/common/remove" method="post" name="org.framework.common.api.entity.CommonMessage"></form>
			
<!-- Javascript ===================================================== -->
<script src="/miwawa/resources/lib/miwawa/1.0.2/js/core/requirejs/require.js"></script>

<script type="text/javascript">
<!--
	jQuery(function(){
		require(['/miwawa/resources/lib/miwawa/1.0.2/js/core/module/app/simple.js'], function(simple){
			simple(['registerForm','registerTable','registerWidget']);
		});
		jQuery.ajaxsend({
			url:"/miwawa/default/common/search.json",
			async:false,
			data:{
				 "entityClass":"com.app.miwawa.api.system.entity.view.ShopView",
			    "and[0][operator]": "EQ",
		      "and[0][fieldName]": "invalid",					// 删除标识
		      "and[0][fieldValue]": "F",						// F=有效的<未删除>、T=无效的<已删除>
		      "and[1][operator]": "EQ",
		      "and[1][fieldName]": "status",					// 状态标识
		      "and[1][fieldValue]": "0",						// 默认为0
		      "and[2][operator]": "EQ",
		      "and[2][fieldName]": "dbname",				// 早教中心数据源
		      "and[2][fieldValue]": dbname	        // dbname
			},
			success:function(data){
		      var dataList = data.rows;
		      for(var i=0;i<dataList.length;i++){
		          $("#info").val(dataList[0].id);
		      }
			}			
	  });
	});
	

	function renderOperator(value, row, index){
		return "<a class='btn btn-info     btn-xs btn-table-op' onclick='handlerSend(this, \""+row.id+"\")' data-table-source='#table-notify' data-form-source='#send-form-notify' data-toggle='tooltip' data-placement='top' title='重新发送'> <i class='fa fa-paper-plane-o'></i> </a>"
				 + "<a class='btn btn-warning	 btn-xs btn-table-op' onclick='handlerModify(this, \""+row.id+"\", \"close\")' data-table-source='#table-notify' data-form-source='#modify-form-notify' data-toggle='tooltip' data-placement='top' title='关闭'> <i class='fa fa-ban'></i> </a>"				 
				 + "<a class='btn btn-danger   btn-xs btn-table-op' onclick='handlerRemove(this, \""+row.id+"\")' data-table-source='#table-notify' data-form-source='#remove-form-notify' data-toggle='tooltip' data-placement='top' title='删除'> <i class='fa fa-trash'></i> </a>";
	}
	
	function handlerSend(button, id){		
		jQuery.ajaxsend({
			url:"/miwawa/message/resend/"+id,
			success:function(data){
				if(!data.error) {
					jQuery(button).tooltip("destroy");
					jQuery("#table-notify").bootstrapTable("refresh");
				}else{
					jQuery.message.warning(data.error);
				}
			}
		});
	}

//-->
</script>
